<?php header("Content-Type:text/html;   charset=utf-8"); ?>
<script type="text/javascript">
	$(function(){
		loadUser();
		loadCity();
		$("#btnQuery").bind("click",loadUser);	
		$("#selProvince").bind("change",loadCity);
		$("#hrefDel").bind("click",delSelect);
		$("#hrefSetGroup").bind("click",setUserGroup);
				
	});
	function loadCity(){
		$("#selCity").html("<option value=''>请选择...</option>");
		var pid = $("#selProvince").val();
		if(IsEmpty(pid))
			return;
		var params = {provinceid : pid};
		$.ajax({
			type:"post",
			url:"admin.php/City/getByProvinceId",
			dataType:"html",
			data:params,
			async:false,
			success:function(data){
				$("#selCity").append(data);
			}
		});
	}
 	function delSelect(){
 	 	var selIds=getSelectIds();
 	 	if(selIds==""){
 	 	 	alert('请选择要删除的项');
 	 	 	return;
 	 	}
 	 	if(confirm('删除后不可恢复，确认要删除吗？')==false)
 	 	 	return;
 	 	var params={uid:selIds};
 	 	var url="admin.php/manage/delUser";
 	 	$.ajax({
 	 	 	type:"post",
 	 	 	url:url,
 	 	 	dataType:"json",
 	 	 	data:params,
 	 	 	success:function(data){
				if(data.ReturnCode=="1"){
					loadUser();
					alert('删除成功');
				}else{
					alert('删除失败');
				}
 	 	 	}
 	 	});
 	}
 	
	function getSelectIds(){
		var sel = "";
		$("#tableUserManage td :checkbox:checked").each(function(){
			sel+=$(this).val()+",";
		});
		return sel;
	}
	function setUserGroup(){
		var selIds = getSelectIds();		
		if(IsEmpty(selIds)){
			alert("请先选择要操作的项");
			return;
		}
		$("#hrefEditUserManage").attr("href","admin.php/manage/selGroup");
		$("#hrefEditUserManage").trigger("click");
	}
	function modifyUserGroup(gid){
		var selIds = getSelectIds();		
		if(IsEmpty(selIds)){
			alert("请先选择要操作的项");
			return;
		}
		var params = {
					gid:gid,
					ids:selIds
				};		
		$.ajax({
			type:"post",
			url:"admin.php/manage/modifyUserGroup",
			dataType:"json",
			data:params,
			async:false,
			success:function(data){												
				loadUser();
			}
		});
	}
	function loadUser(){
		$("#chkSelectAll").attr("checked",false);
		var params={
					realname:$("#txtRealName").val(),
					provinceid:$("#selProvince").val(),
					cityid:$("#selCity").val(),
					sex:$("#selSex").val(),
					minAge:$("#selAge").find("option:selected").attr("min"),
					maxAge:$("#selAge").find("option:selected").attr("max"),
					idstatus:$("#selIdCard").val(),					
					status:$("#selStatus").val()
				};		
		var url="admin.php/manage/loadUser";
		$.ajax({
			type:"post",
			url:url,
			dataType:"html",
			data:params,
			success:function(data){
				$("#tableUserManage").html(data);
				$("#divtest").html(data);
				bindSelect("chkSelectAll","tableUserManage");				
			}
		});	
	}
	function modify(id){		
		$("#hrefEditUserManage").attr("href","admin.php/manage/newuser?id="+id).text("基本信息");
		$("#hrefEditUserManage").trigger("click");
	}
	function del(id){
		if(confirm('删除后不可恢复，确定要继续删除吗？')){
			var params = {uid:id};
			var url="admin.php/manage/delUser";
			$.ajax({
				type:"post",
				url:url,
				dataType:"json",
				data:params,
				success:function(data){
					
					if(data.ReturnCode=="1"){
						loadUser();
						alert('删除成功');
					}else{
						alert('删除失败');
					}
				}
			});
		}
	}
	function auditIdCardManage(id){
		$("#hrefEditUserManage").attr("href","admin.php/manage/auditCard?id="+id).text("认证管理");
		$("#hrefEditUserManage").trigger("click");
	}

	function mamageAlbum(id){
		$("#hrefEditUserManage").attr("href","admin.php/manage/album?id="+id).text("相册管理");
		$("#hrefEditUserManage").trigger("click");
	}
</script>

<div class="pageHeader">
	<form onsubmit="return navTabSearch(this);" action="demo_page1.html"
		method="post">
		<div class="searchBar">
			<table class="searchContent">
				<tr>
					<td>模特名称：<input type="text" id="txtRealName"/>
					</td>
					<td>居住地：<select id="selProvince" name="selProvince" style="width: 80px">
							<option value=''>请选择...</option>
					<?php					
					foreach ( $province as $key => $value ) {
						print "<option value='$key'>$value</option>";
					}
					?>
					</select> -
					
					<select id="selCity" name="selCity" style="width:80px">
					<option value="">请选择...</option>
					</select>
					</td>
					<td>性别：<select id="selSex" style="width:80px">
					<option value="">请选择...</option>
					<option value="男">男</option>
					<option value="女">女</option>
					</select>  </td>
					<td>年龄：<select id="selAge">
					<option value="" min="" max="">请选择...</option>
					<option value="1" min="" max="20">20岁以下</option>
					<option value="2" min="20" max="30">20-30岁</option>
					<option value="3" min="30" max="">30岁以上</option>
					</select></td>
					<td>
					身份认证：
					<select id="selIdCard">
					<option value="">请选择...</option>
					<option value="1">未提交</option>
					<option value="2">待认证</option>
					<option value="3">通过认证</option>
					<option value="4">驳回认证</option>
					</select>
					</td>
					<td>是否会员：<select id="selStatus"
						style="width: 80px">
							<option value=''>请选择...</option>
							<option value="1">是</option>
							<option value="0">否</option>
					</select></td>
					<td>
						<div class="subBar">
							<ul>
								<li><div class="buttonActive">
										<div class="buttonContent">
											<button id="btnQuery" type="button" style="width: 100px">查&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;询</button>
										</div>
									</div></li>
							</ul>
						</div>
					</td>
				</tr>
			</table>

		</div>
	</form>
</div>
<div class="pageContent">
	<div class="panelBar">
		<ul class="toolBar">			
			<li style="display: none"><a id="hrefEditUserManage" class="edit"
				href="" lookupgroup="orgLookup"><span>修改</span></a></li>
			<li><a id="hrefSetGroup" class="edit"
				href="javascript:void(0)"><span>设置用户组</span></a></li>
			<li><a id="hrefDel" class="delete"
				href="javascript:void(0)"><span>删除</span></a></li>
			<li><a id="hrefExport" class="edit"
				href="javascript:void(0)"><span>导出</span></a></li>
		</ul>
	</div>
	<table class="table" width="100%" layoutH="138">
		<thead>
			<tr>
				<th style='width: 30px;text-align:center;'><input type='checkbox'
					id='chkSelectAll' /></th>
				<th style='width:40px'>编号</th>
				<th style='width: 120px'>用户名</th>
				<th style='width: 100px'>姓名</th>
				<th style='width: 60px'>性别</th>
				<th style='width: 60px'>年龄</th>
				<th style='width: 120px'>地区</th>
				<th style='width: 100px'>注册时间</th>
				<th style='width: 100px'>认证方式</th>
				<th style='width: 100px'>认证结果</th>
				<th style='width: 200px'>模特类型</th>
				<th style='width: 60px'>是否会员</th>
				<th style='width: 260px'>操作</th>
				
			</tr>
		</thead>
		<tbody id="tableUserManage">

		</tbody>
		
	</table>
	
</div>





























